class Keploy < Formula
  desc "Testing Toolkit creates test-cases and data mocks from API calls, DB queries"
  homepage "https://keploy.io"
  url "https://github.com/keploy/keploy/archive/refs/tags/v2.11.25.tar.gz"
  sha256 "4350dad0dfa007066fe0d0afbc087aaa3ccf6e7e445dedbfa03b0a23a98bf21a"
  license "Apache-2.0"
  head "https://github.com/keploy/keploy.git", branch: "main"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_tahoe:   "f303195b2b1c78ed94473c055f204d9f2bd41e24e482fabd561d6e7b00d7e647"
    sha256 cellar: :any_skip_relocation, arm64_sequoia: "f303195b2b1c78ed94473c055f204d9f2bd41e24e482fabd561d6e7b00d7e647"
    sha256 cellar: :any_skip_relocation, arm64_sonoma:  "f303195b2b1c78ed94473c055f204d9f2bd41e24e482fabd561d6e7b00d7e647"
    sha256 cellar: :any_skip_relocation, sonoma:        "7c89ac21da29316657f76f15dddae7e61da02bfc020a45648ecfed2b621e1caa"
    sha256 cellar: :any_skip_relocation, arm64_linux:   "95800a1643990d5e99c715823e7445da838f8c0422d37999a3832dc5b63f8542"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "a39da873f48341e5949999ba4717c1bb6c6a7514aba2599d05a818a606a6830d"
  end

  depends_on "go" => :build

  def install
    system "go", "build", *std_go_args(ldflags: "-s -w -X main.version=#{version}")
  end

  test do
    system bin/"keploy", "config", "--generate", "--path", testpath
    assert_match "# Generated by Keploy", (testpath/"keploy.yml").read

    output = shell_output("#{bin}/keploy templatize --path #{testpath}")
    assert_match "No test sets found to templatize", output

    assert_match version.to_s, shell_output("#{bin}/keploy --version")
  end
end
